#首页上的火车页面


from selenium.webdriver.common.by import By
from common.commontools import decorator
from common.basedriver import BaseDriver


class TrainMainPage(BaseDriver):

    #出发站的输入框
    @decorator()
    def dep_main_train_input(self):
        return self.find_element(By.CSS_SELECTOR,"input#notice01")

    #到达站的输入框
    @decorator()
    def arr_main_train_input(self):
        return self.find_element(By.CSS_SELECTOR,"input#notice02")

    #出发日期
    @decorator()
    def dep_main_train_date(self):
        return self.find_element(By.CSS_SELECTOR,"input#DdateObj")

    #返程日期
    @decorator()
    def back_main_train_date(self):
        return self.find_element(By.CSS_SELECTOR,"input#AdateObj")

    #搜索框
    @decorator()
    def search_button(self):
        return self.find_element(By.CSS_SELECTOR,"#searchTicket")

    # 国内火车票
    @decorator()
    def inside_train(self):
        return self.find_element(By.XPATH, "//*[@id='trainSwitch']/a[text()='国内火车票']")

    #请输入出发城市名称，用于断言
    @decorator()
    def depart_city_warn(self):
        return self.find_element(By.XPATH,"//div[text()='请输入出发城市名称']")

    #请输入到达城市名称，用于断言
    @decorator()
    def arrive_city_warn(self):
        return self.find_element(By.XPATH,"//div[text()='请输入到达城市名称']")

    #请选择出发日期,用于断言
    @decorator()
    def select_date_warn(self):
        return self.find_element(By.XPATH,"//div[text()='请选择出发日期']")

    #请选择返回日期，用于断言
    @decorator()
    def select_back_date_warn(self):
        return self.find_element(By.XPATH,"//div[text()='请选择返回日期']")

    #往返
    @decorator()
    def round_trip(self):
        return self.find_element(By.ID,"roundTrip")
    #单程
    @decorator()
    def sigle_trip(self):
        return self.find_element(By.ID,"singleTrip")
    #中转
    @decorator()
    def hub_trip(self):
        return self.find_element(By.ID,"hubTrip")

    #中转站
    def hub_station(self):
        return self.find_element(By.CSS_SELECTOR,"#notice03")

    #换
    @decorator()
    def change_button(self):
        return self.find_element(By.XPATH,"//div[@id='train']//a[text()='换']")

    #刷新页面
    def reflesh_url(self):
        self.driver.refresh()




